package com.ssy.lingxi.order.repository;

import com.ssy.lingxi.order.entity.OrderDO;
import com.ssy.lingxi.order.entity.OrderPaymentDO;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * 订单支付记录Jpa仓库
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-17
 */
@Repository
public interface OrderPaymentRepository extends JpaRepository<OrderPaymentDO, Long>, JpaSpecificationExecutor<OrderPaymentDO> {
    List<OrderPaymentDO> findByOrder(OrderDO order);

    List<OrderPaymentDO> findByOrder(OrderDO order, Sort sort);

    List<OrderPaymentDO> findByOrderIn(List<OrderDO> orders);

    List<OrderPaymentDO> findByOrderAndSerialNo(OrderDO order, Integer serialNo);

    List<OrderPaymentDO> findByOrderAndBatchNoGreaterThanEqualAndBatchNoLessThanEqual(OrderDO order, Integer minBatchNo, Integer maxBatchNo);

    List<OrderPaymentDO> findByOrderAndPayAmountGreaterThan(OrderDO order, BigDecimal payAmount, Sort sort);

    List<OrderPaymentDO> findByOrderInAndPayAmountGreaterThanAndOuterStatusIn(List<OrderDO> orders, BigDecimal payAmount, List<Integer> outerStatus);

    @Transactional
    void deleteByOrder(OrderDO order);
}
